Beginning Android Games by Mario Zechner & Robert Green
Author:Mario Zechner & Robert Green [Zechner, Mario & Green, Robert]
Language: eng
Format: epub
Tags: Hardware, Programming, Handheld Devices, Games, Computers
ISBN: 9781430246770
Publisher: Apress
Published: 2012-10-31T04:00:00+00:00
Alpha Blending: I Can See Through You
Alpha blending in OpenGL ES is pretty easy to enable. We only need two method calls:
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
The first method call should be familiar: it just tells OpenGL ES that it should apply alpha blending to all triangles we render from this point on. The second method is a little bit more involved. It specifies how the source color and destination color should be combined. Recall from Chapter 3 that the way a source color and a destination color are combined is governed by a simple blending equation. The method glBlendFunc() just tells OpenGL ES which kind of equation to use. The preceding parameters specify that we want the source color to be mixed with the destination color exactly as specified in the blending equation in Chapter 3. This is equal to how the Canvas blended Bitmaps for us.
Blending in OpenGL ES is pretty powerful and complex, and there’s a lot more to it. For our purposes, we can ignore all those details, though, and just use the preceding blending function whenever we want to blend our triangles with the framebuffer—the same way we blended Bitmaps with the Canvas.
The second question is where the source and destination colors come from. The latter is easy to explain: it’s the color of the pixel in the framebuffer we are going to overwrite with the triangle we draw. The source color is actually a combination of two colors.
The vertex color: This is the color we either specify via glColor4f() for all vertices or specify on a per-vertex basis by adding a color attribute to each vertex.
The texel color: As mentioned before, a texel is a pixel from a texture. When our triangle is rendered with a texture mapped to it, OpenGL ES will mix the texel colors with the vertex colors for each pixel of a triangle.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12626)
Hello! Python by Anthony Briggs(9941)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9817)
The Mikado Method by Ola Ellnestam Daniel Brolund(9807)
Dependency Injection in .NET by Mark Seemann(9365)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8326)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7782)
Grails in Action by Glen Smith Peter Ledbrook(7718)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7585)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7312)
Microservices with Go by Alexander Shuiskov(7076)
Practical Design Patterns for Java Developers by Miroslav Wengner(6999)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6936)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6441)
Angular Projects - Third Edition by Aristeidis Bampakos(6351)
The Art of Crafting User Stories by The Art of Crafting User Stories(5877)
NetSuite for Consultants - Second Edition by Peter Ries(5801)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5616)
Kotlin in Action by Dmitry Jemerov(5088)
